<script setup>
// uni.navigateBack(2)
import { inject, ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
const type = ref("");
onLoad((e) => {
  if (e.type) {
    type.value = e.type;
  } else {
    type.value = 2;
  }
});

const gohome = () => {
  // uni.navigateBack()
  uni.reLaunch({
    url: "/pages/index/index",
  });

  return;
  let pages = getCurrentPages();

  // 获取页面栈的长度，即页面跳转层级
  let level = pages.length;
  if (level > 1) {
    uni.navigateBack();
  } else {
    uni.switchTab({
      url: "/pages/my/index",
    });
  }
};
const fhfun = () => {
  let pages = getCurrentPages();

  // 获取页面栈的长度，即页面跳转层级
  let level = pages.length;
  if (level > 1) {
    uni.navigateBack(4);
  } else {
    uni.reLaunch({
      url: "/pages/index/index",
    });
  }
  // uni.reLaunch({ url: "/pages/order/orderlist/index?status=-2" });
};
const goorderfun = () => {
  uni.reLaunch({
    url: "/pages/order/orderlist/index?status=-2",
  });
};
</script>
<template>
  <view class="paycontent">
    <view :class="type == 1 ? 'pay-hx' : type == 2 ? 'pay-hx pay-err' : ''">
    </view>
    <view class="pay-res" v-if="type == 1">
      <view class="pay-res-img">
        <image src="@/static/icon_successful.png" mode=""></image>
      </view>
      <view class="pay-res-name"> 提交成功 </view>
      <view class="pay-res-dec"> 您已升级成功 </view>
      <view class="pay-res-k">
        <view class="pay-res-see" @click="goorderfun"> 查看订单 </view>
        <view class="pay-res-bt" @click="gohome"> 返回首页 </view>
      </view>
    </view>

    <view class="pay-res" v-if="type == 2">
      <view class="pay-res-img">
        <image src="@/static/icon_error.png" mode=""></image>
      </view>
      <view class="pay-res-name"> 支付失败 </view>
      <view class="pay-res-dec"> 支付失败,可前往未支付订单支付 </view>
      <view class="pay-res-k">
        <view class="pay-res-see refresh-pay" @click="fhfun"> 返回 </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
@import "upgradestate.scss";
</style>
